package com.xmhmyh.generalframework.project.sys.controller;

import com.xmhmyh.generalframework.common.conversion.Enum2SelectVOConversion;
import com.xmhmyh.generalframework.common.entity.Response;
import com.xmhmyh.generalframework.common.enums.ResponseCode;
import com.xmhmyh.generalframework.common.vo.SelectVO;
import com.xmhmyh.generalframework.framework.exceptions.ManageExceptions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 于丁
 * @DateTime: 2020/8/18 11:32 上午
 */
@RestController
@RequestMapping("/sys/enum")
public class EnumController {

    @PostMapping("getEnumSelectData")
    public Response getEnumSelectVO(String enumClassName) {
        try {
            Class eClass = Class.forName(enumClassName);
            List<SelectVO> selectVOList = Enum2SelectVOConversion.conversion(eClass);
            return Response.success(selectVOList);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            throw new ManageExceptions(ResponseCode.ENUM_NOT_FIND);
        }
    }

}
